﻿using System;
using System.Collections.Generic;

namespace YArchitech.Plumbing
{
	internal class HYHydrantGroup
	{
		public HYHydrantGroup()
		{
		}

		public HYHydrantGroup(HYHydrantGroup src)
		{
			this.m_DAGroup = new List<double>();
			foreach (double item in src.m_DAGroup)
			{
				this.m_DAGroup.Add(item);
			}
		}

		public int GetSize()
		{
			return this.m_DAGroup.Count;
		}

		public void SetSize(int nCount)
		{
			this.m_DAGroup.Clear();
			for (int i = 0; i < nCount; i++)
			{
				this.m_DAGroup.Add(0.0);
			}
		}

		public double GetAt(int nIndex)
		{
			if (nIndex >= this.m_DAGroup.Count || nIndex <= -1)
			{
				return 0.0;
			}
			return this.m_DAGroup[nIndex];
		}

		public bool SetAt(int nIndex, double itemdouble)
		{
			if (nIndex < this.GetSize() && nIndex >= 0)
			{
				this.m_DAGroup[nIndex] = itemdouble;
				return true;
			}
			return false;
		}

		public static HYHydrantGroup operator *(HYHydrantGroup op1, double dVale)
		{
			HYHydrantGroup hyhydrantGroup = new HYHydrantGroup();
			foreach (double num in op1.m_DAGroup)
			{
				hyhydrantGroup.m_DAGroup.Add(num * dVale);
			}
			return hyhydrantGroup;
		}

		public static HYHydrantGroup operator /(HYHydrantGroup op1, double dVale)
		{
			HYHydrantGroup hyhydrantGroup = new HYHydrantGroup();
			foreach (double num in op1.m_DAGroup)
			{
				hyhydrantGroup.m_DAGroup.Add(num / dVale);
			}
			return hyhydrantGroup;
		}

		public void Substract(int nIndex, HYHydrantGroup src)
		{
			int size = this.GetSize();
			double at = this.GetAt(nIndex);
			for (int i = nIndex; i < size; i++)
			{
				List<double> dagroup = this.m_DAGroup;
				int index = i;
				dagroup[index] -= src.GetAt(i) * at;
			}
		}

		public void Add(int nIndex, HYHydrantGroup src)
		{
			int size = this.GetSize();
			double at = this.GetAt(nIndex);
			for (int i = nIndex; i < size; i++)
			{
				List<double> dagroup = this.m_DAGroup;
				int index = i;
				dagroup[index] += src.GetAt(i) * at;
			}
		}

		public List<double> m_DAGroup = new List<double>();
	}
}
